package com.roshan.web.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.springframework.util.StringUtils;

import com.roshan.web.util.constants.CommonConstants;

/**
 * The Class UpdateUserProfile.
 */
@SuppressWarnings("nls")
public class UpdateUser implements Serializable {

    /** The Constant serialVersionUID. */
    private static final long serialVersionUID = 100L;

    /** The username. */
    private String username;

    /** The full name. */
    private String fullName;

    /** The first name. */
    private String firstName;

    /** The last name. */
    private String lastName;

    /** The email. */
    private String email;

    /** The mobile. */
    private String mobile;

    /** The mobile first section. */
    private String mobileFirstSection;

    /** The mobile second section. */
    private String mobileSecondSection;

    /** The mobile third section. */
    private String mobileThirdSection;

    /** The user profile uri. */
    private String userProfileUri;

    /** The tenant profile uri. */
    private String tenantProfileUri;

    /** The partner profile uri. */
    private String partnerProfileUri;

    /** The device types. */
    private List<String> deviceTypes = new ArrayList<String>();

    /** The old username. */
    private String oldUsername;

    /** The old first name. */
    private String oldFirstName;

    /** The old last name. */
    private String oldLastName;

    /** The old email. */
    private String oldEmail;

    /** The old mobile. */
    private String oldMobile;

    /** The show username. */
    private boolean showUsername = true;

    /**
     * Gets the first name.
     * 
     * @return the firstName
     */
    public String getFirstName() {
        return this.firstName;
    }

    /**
     * Sets the first name.
     * 
     * @param firstName the firstName to set
     */
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    /**
     * Gets the last name.
     * 
     * @return the lastName
     */
    public String getLastName() {
        return this.lastName;
    }

    /**
     * Sets the last name.
     * 
     * @param lastName the lastName to set
     */
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    /**
     * Gets the email.
     * 
     * @return the email
     */
    public String getEmail() {
        return this.email;
    }

    /**
     * Sets the email.
     * 
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * Gets the mobile.
     * 
     * @return the mobile
     */
    public String getMobile() {
        this.mobile = "";
        this.mobile = concatMobileNumberSection(this.mobile, this.mobileFirstSection);
        this.mobile = concatMobileNumberSection(this.mobile, this.mobileSecondSection);
        this.mobile = concatMobileNumberSection(this.mobile, this.mobileThirdSection);
        return this.mobile;
    }

    /**
     * Sets the mobile. 0001113331
     * 
     * @param mobile the mobile to set
     */
    public void setMobile(String mobile) {
        if (StringUtils.hasText(mobile)) {
            this.mobileFirstSection = mobile.substring(0, 3);
            this.mobileSecondSection = mobile.substring(3, 6);
            this.mobileThirdSection = mobile.substring(6);
        }
        this.mobile = mobile;
    }

    /**
     * Gets the old first name.
     * 
     * @return the oldFirstName
     */
    public String getOldFirstName() {
        return this.oldFirstName;
    }

    /**
     * Sets the old first name.
     * 
     * @param oldFirstName the oldFirstName to set
     */
    public void setOldFirstName(String oldFirstName) {
        this.oldFirstName = oldFirstName;
    }

    /**
     * Gets the old last name.
     * 
     * @return the oldLastName
     */
    public String getOldLastName() {
        return this.oldLastName;
    }

    /**
     * Sets the old last name.
     * 
     * @param oldLastName the oldLastName to set
     */
    public void setOldLastName(String oldLastName) {
        this.oldLastName = oldLastName;
    }

    /**
     * Gets the old email.
     * 
     * @return the oldEmail
     */
    public String getOldEmail() {
        return this.oldEmail;
    }

    /**
     * Sets the old email.
     * 
     * @param oldEmail the oldEmail to set
     */
    public void setOldEmail(String oldEmail) {
        this.oldEmail = oldEmail;
    }

    /**
     * Gets the old mobile.
     * 
     * @return the oldMobile
     */
    public String getOldMobile() {
        return this.oldMobile;
    }

    /**
     * Sets the old mobile.
     * 
     * @param oldMobile the oldMobile to set
     */
    public void setOldMobile(String oldMobile) {
        this.oldMobile = oldMobile;
    }

    /**
     * Gets the tenant profile uri.
     * 
     * @return the tenantProfileUri
     */
    public String getTenantProfileUri() {
        return this.tenantProfileUri;
    }

    /**
     * Sets the tenant profile uri.
     * 
     * @param tenantProfileUri the tenantProfileUri to set
     */
    public void setTenantProfileUri(String tenantProfileUri) {
        this.tenantProfileUri = tenantProfileUri;
    }

    /**
     * Gets the partner profile uri.
     * 
     * @return the partnerProfileUri
     */
    public String getPartnerProfileUri() {
        return this.partnerProfileUri;
    }

    /**
     * Sets the partner profile uri.
     * 
     * @param partnerProfileUri the partnerProfileUri to set
     */
    public void setPartnerProfileUri(String partnerProfileUri) {
        this.partnerProfileUri = partnerProfileUri;
    }

    /**
     * Gets the device types.
     * 
     * @return the deviceTypes
     */
    public List<String> getDeviceTypes() {
        return this.deviceTypes;
    }

    /**
     * Sets the device types.
     * 
     * @param deviceTypes the deviceTypes to set
     */
    public void setDeviceTypes(List<String> deviceTypes) {
        this.deviceTypes = deviceTypes;
    }

    /**
     * Gets the user profile uri.
     * 
     * @return the userProfileUri
     */
    public String getUserProfileUri() {
        return this.userProfileUri;
    }

    /**
     * Sets the user profile uri.
     * 
     * @param userProfileUri the userProfileUri to set
     */
    public void setUserProfileUri(String userProfileUri) {
        this.userProfileUri = userProfileUri;
    }

    /**
     * Gets the mobile first section.
     * 
     * @return the mobileFirstSection
     */
    public String getMobileFirstSection() {
        return this.mobileFirstSection;
    }

    /**
     * Sets the mobile first section.
     * 
     * @param mobileFirstSection the mobileFirstSection to set
     */
    public void setMobileFirstSection(String mobileFirstSection) {
        this.mobileFirstSection = mobileFirstSection;
    }

    /**
     * Gets the mobile second section.
     * 
     * @return the mobileSecondSection
     */
    public String getMobileSecondSection() {
        return this.mobileSecondSection;
    }

    /**
     * Sets the mobile second section.
     * 
     * @param mobileSecondSection the mobileSecondSection to set
     */
    public void setMobileSecondSection(String mobileSecondSection) {
        this.mobileSecondSection = mobileSecondSection;
    }

    /**
     * Gets the mobile third section.
     * 
     * @return the mobileThirdSection
     */
    public String getMobileThirdSection() {
        return this.mobileThirdSection;
    }

    /**
     * Sets the mobile third section.
     * 
     * @param mobileThirdSection the mobileThirdSection to set
     */
    public void setMobileThirdSection(String mobileThirdSection) {
        this.mobileThirdSection = mobileThirdSection;
    }

    /**
     * Gets the username.
     * 
     * @return the username
     */
    public String getUsername() {
        return this.username;
    }

    /**
     * Sets the username.
     * 
     * @param username the username to set
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * Gets the old username.
     * 
     * @return the oldUsername
     */
    public String getOldUsername() {
        return this.oldUsername;
    }

    /**
     * Sets the old username.
     * 
     * @param oldUsername the oldUsername to set
     */
    public void setOldUsername(String oldUsername) {
        this.oldUsername = oldUsername;
    }

    /**
     * Checks if is show username.
     * 
     * @return the showUsername
     */
    public boolean isShowUsername() {
        return this.showUsername;
    }

    /**
     * Sets the show username.
     * 
     * @param showUsername the showUsername to set
     */
    public void setShowUsername(boolean showUsername) {
        this.showUsername = showUsername;
    }

    /**
     * Gets the full name.
     * 
     * @return the fullName
     */
    public String getFullName() {
        return this.fullName;
    }

    /**
     * Sets the full name.
     * 
     * @param fullName the fullName to set
     */
    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    /**
     * Concat mobile number section.
     * 
     * @param mobileParam the mobile param
     * @param section the section
     * @return the string
     */
    private String concatMobileNumberSection(String mobileParam, String section) {

        String mobileNumber = mobileParam;
        if (StringUtils.hasText(section)) {
            mobileNumber += section;
        }
        return mobileNumber;
    }

    /**
     * Split full name in to the first name and last name.
     */
    public void splitFullName() {
        this.lastName = CommonConstants.EMPTY;
        String[] nameParts = this.fullName.split(CommonConstants.SPACE);
        this.firstName = nameParts[0].trim();
        for (int i = 1; i < nameParts.length; i++) {
            this.lastName = this.lastName
                    + ((CommonConstants.EMPTY.equals(this.lastName)) ? nameParts[i] : CommonConstants.SPACE
                            + nameParts[i]);
        }

        this.lastName = this.lastName.trim();
    }

}
